<template>
	<hyb-page :title="info.y_name">
		<!-- 请开始您的开发 ~ -->
		<template v-slot:body>
			<view class="gui-list gui-padding" :style="{'background':base.qjcolor}">
				<view class="gui-list-items">
					<image style="height: 260rpx; width: 200rpx;border-radius: 10rpx;"
						:src="info.y_thumb||$store.state.base.yg_set.yg_xq_tu"
						mode="aspectFill">
					</image>
					<view class="gui-list-body">
						<view class="gui-list-title">
							<text class="gui-list-title-text gui-color-white">{{info.y_name}}</text>
						</view>
						<view class="gui-list-body-desc gui-margin-top">
							<view class="gui-color-white gui-flex">
								<text class="gui-color-white gui-flex1">好评率：100%</text>
								<text class="gui-color-white gui-flex1">已服务：{{info.fw_count}}单</text>
							</view>

							<view v-if="info.uniacid !== 15" class="gui-color-white gui-flex gui-margin-top-middle">
								<text class="gui-color-white gui-flex1">性别：{{info.y_sex}}</text>
								<text class="gui-color-white gui-flex1">状态：{{info.y_typs}}</text>
							</view>


							<view class="gui-color-white gui-flex gui-margin-top-middle">
								<text v-if="info.uniacid !== 15"
									class="gui-color-white gui-flex1">年龄：{{info.y_age}}</text>
								<text class="gui-color-white gui-flex1 gui-ellipsis">已缴保证金：{{info.baozhengjin}}</text>
							</view>



							<view v-if="$store.state.base.yg_set.yg_dz"
								class="gui-color-white gui-flex gui-margin-top-middle">

								<text class="gui-color-white gui-flex1">地址：{{info.y_address}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>


			<view class="gui-bg-white gui-dark-bg-level-3 gui-padding" v-if="$store.state.base.yg_set.sfzx_dh">
				<gui-switch-navigation :currentIndex="navIndex" :items="$store.state.base.yg_set.sfzx_type_arr"
					@change="navchange" textAlign="center" :isCenter="true" activeDirection="center" :size="0"
					:margin="20" padding="30rpx"></gui-switch-navigation>
			</view>

			<view v-if="id==2" class="gui-margin-top gui-bg-white">

				<hyb-comments v-if="pingjiaLit" :list="pingjiaLit"></hyb-comments>
				<hyb-empty height="50vh" content="暂无评价" v-if="pingjiaLit.length == 0"></hyb-empty>
			</view>

			<view v-if="id==1" class="gui-margin-top">
				<view class="gui-bg-white">
					<hyb-grid width="200" v-if="info.y_jinengs" :columns="3" :items="info.y_jinengs"
						:keys="['xt_thumb','xt_name']" @item_click="goto">
					</hyb-grid>
				</view>
			</view>



			<!-- 师傅已完成的订单 -->
			<view v-if="id == 3">
				<hyb-empty height="50vh" content="暂无订单" v-if="orders.length == 0"></hyb-empty>
				<view v-for="(item,index) in orders" :key="index"
					class="gui-bg-white gui-padding gui-border-b gui-margin-top-middle">

					<view class="gui-flex gui-space-between gui-align-items-center">

						<view class="gui-text gui-bold gui-color-gray" v-if="order_list_style==1">
							{{item.fa_fwstyle1}}-{{item.fa_fwstyle2}}
						</view>

						<gui-tags v-else :size="22" style="margin: 0;" :text="item.order_type"
							:customClass="[tags[item.order_type],'gui-color-white','gui-ellipsis']">
						</gui-tags>



						<text class="gui-text-small gui-color-black">订单号：{{ item.fa_ordersn}}</text>
					</view>

					<view v-if="order_list_style!=1">
						<view
							:url="'/hyb_o2o/inner/pages/fabu/detail?id=' + (item.fa_id) +'&tag=' + this.filterData.tag +'&t_y_id=' + t_y_id"
							class="gui-margin-top gui-border-t">
							<view class="gui-text-small gui-padding-y gui-color-gray"
								@tap="toDetail(item.fa_id,item.o_status)">
								{{item.fa_fwcontent}}
							</view>
							<view class="gui-text gui-flex gui-align-items-center gui-space-between"
								@tap="toDetail(item.fa_id,item.o_status)">
								<view>发布人：
									<text class="gui-color-gray gui-margin-x-small gui-text-small">{{item.fa_name}}
									</text>
									<text class="gui-color-gray gui-margin-x-small gui-text-small">{{item.fa_time}}
									</text>
								</view>
								<text class="gui-icons gui-color-gray gui-margin-left">&#xe601;</text>
							</view>
							<view @tap="toDetail(item.fa_id,item.o_status)"
								class="gui-text gui-flex gui-align-items-center gui-margin-top-middle"><text
									class="gui-flex-shrink0">地址：</text><text
									class="gui-color-gray gui-text-small gui-margin-x-small">{{item.fa_fwaddress}}{{item.fa_fwaddresss}}
								</text>
							</view>



							<view v-if="item.fa_fwmoney  > 0 && item.o_status != 0"
								class="gui-text gui-flex gui-align-items-center gui-margin-top-middle gui-space-between">
								<view class="gui-flex gui-align-items-center">订单额：
									<text class="gui-color-gray gui-text-small gui-margin-x-small gui-color-gray"
										style="margin-left: -5rpx;">{{parseFloat(item.fa_fwmoney).toFixed(0)}}</text>
									<view v-if="filterData.tag=='yg'" class="gui-flex gui-align-items-center">
									</view>
								</view>

								<view
									v-if="item.o_status != 0 && filterData.tag=='yg' || filterData.tag=='dl' || filterData.tag=='manage'"
									class="gui-flex gui-align-items-center">
									<view class="gui-margin-x " v-if="item.pt_fengyong >= 1">已付佣：</view>
									<view class="gui-text-small gui-color-gray" v-if="item.pt_fengyong  >= 1"
										style="margin-left: -30rpx;">
										{{parseFloat(item.pt_fengyong).toFixed(0)}}
									</view>

									<view class="gui-margin-x " v-if="item.pt_wzf_fengyong >= 1">待付佣：</view>
									<view class="gui-text-small gui-color-gray" v-if="item.pt_wzf_fengyong  >= 1"
										style="margin-left: -30rpx;">
										{{parseFloat(item.pt_wzf_fengyong).toFixed(0)}}
									</view>


								</view>

							</view>

							<view
								class="gui-text gui-flex gui-align-items-center gui-margin-top-middle gui-space-between">
								<view v-if="order_list_style == 2" class="gui-flex gui-align-items-center"
									@tap="toDetail(item.fa_id,item.o_status)">接单：
									<text
										class="gui-color-gray gui-text-small gui-margin-x-small gui-color-gray">{{item.yuangong?item.yuangong.y_name:'无'}}</text>
								</view>
								<view v-else class="gui-text gui-flex gui-align-items-center"> 状态：

									<text v-if="item.o_status == 30 || item.o_status == 35"
										class="gui-color-gray gui-margin-x-small gui-text-small">已完成</text>

								</view>

							</view>

						</view>
					</view>


				</view>
			</view>

			<view v-if="id==4" class="gui-margin-top gui-bg-white" style="height: calc(100vh - 44px - 530rpx);">
				<view class="gui-flex gui-wrap">
					<view v-if="$store.state.base.yg_set.gzz_sfxs || $store.state.userinfo.is_admin "
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">
						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/gzz.png"
							:show-num="1" :items="info.y_gz_imgs"></hyb-preview>
						<view class="gui-color-black gui-bold">工作照</view>
					</view>

					<view
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">

						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/zjz.png"
							:show-num="1" :items="info.y_zj_imgs"></hyb-preview>
						<view class="gui-color-black gui-bold">证件照</view>
					</view>

					<view  v-if="$store.state.base.yg_set.shz_sfxs || $store.state.userinfo.is_admin "
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">

						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/shz.png"
							:show-num="1" :items="info.y_sh_imgs"></hyb-preview>
						<view class="gui-color-black gui-bold">生活照</view>
					</view>

					<view
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">
						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/wfzjl.png"
							:show-num="1" :items="info.wfzjl_img?[info.wfzjl_img]:[]"></hyb-preview>
						<view class="gui-color-black gui-bold">无犯罪</view>
					</view>

					<view
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">

						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/jkz.png"
							:show-num="1" :items="info.jkz_img?[info.jkz_img]:[]"></hyb-preview>
						<view class="gui-color-black gui-bold">健康证</view>
					</view>

					<view  v-if="$store.state.base.yg_set.zgz_sfxs || $store.state.userinfo.is_admin "
						class="gui-flex gui-column gui-align-items-center gui-justify-content-center gui-padding-y-small">
						<hyb-preview style="padding:0  25rpx;" width="117rpx" height="117rpx"
							placehoder="https://xin-jia-zheng-1300612619.cos.ap-chengdu.myqcloud.com/%E5%B0%8F%E5%9B%BE%E6%A0%87/zgzs.png"
							:show-num="1" :items="info.zgz_img?[info.zgz_img]:[]"></hyb-preview>
						<view class="gui-color-black gui-bold">资格证</view>
					</view>
				</view>
			</view>
		</template>

		<template v-slot:pendant v-if="this.$store.state.base.yg_set.y_call">
			<view style="width: 200rpx">
				<text class="gui-text-small" :style="{color:$store.state.base.qjcolor}">联系TA</text>
				<text :style="{'background':base.qjcolor}"
					class="gui-block pendant gui-color-white gui-icons gui-margin-top-small"
					@tap="phone">&#xe60c;</text>
			</view>
		</template>
	</hyb-page>
</template>
<script>
	export default {
		data() {
			return {
				base: null,
				navIndex: -1,
				id: 0,
				pingjiaLit: [],
				navItems: [],
				info: {
					title: ''
				},
				list: [],
				orders: [],
				filterData: {
					tag: ""
				},
				tags: {
					"需求服务": "gui-bg-primary",
					"订水服务": "gui-bg-green",
					"回收订单": "gui-bg-red",
					"服务订单": "gui-bg-yellow",
					"跑腿订单": "gui-bg-orange",
					"快递订单": "gui-bg-orange",
				},
			}
		},


		computed: {
			base: () => {
				return uni.storage.get("base");
			}
		},

		onLoad(options) {



			if (options.y_id) {
				options.id = options.y_id;
			}
			uni.gPost("yuangong/info", {
				y_id: options.id
			}).then((info) => {
				if (info) {
					this.info = info;
					if (info.pingjiaLit) this.pingjiaLit = info.pingjiaLit;

					let defaultIndex = this.$store.state.base.yg_set.sfzx_type_arr.findIndex((val) => {
						return val.default == 1;
					})
					if (defaultIndex == -1) defaultIndex = 0;

					this.navchange(defaultIndex);
				} else {
					uni.showModal({
						title: "提示信息",
						// content: "申请还在审核中，请稍候再来...",
						content: "未查到本" + this.$store.state.base.show_base.shifu_bie_ming + "信息，或已注销。",
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								uni.gJs.back();
							}
						}
					})

				}


			})



		},
		methods: {
			phone() {

				if (this.$store.state.base.yg_set && this.$store.state.base.yg_set.y_telphone_money > 0) {
					const money = this.$store.state.base.yg_set.y_telphone_money
					uni.gPost("yuangong/phone", {
						y_id: this.info.y_id
					}).then((flag) => {
						if (flag > 0) {
							uni.makePhoneCall({
								phoneNumber: this.info.y_telphone
							})
						} else {
							uni.showActionSheet({
								title: '需要支付' + money + '元费用后才能拨打电话!',
								itemList: ["余额支付", "微信支付"],
								success: (res2) => {
									uni.$pay.pay("pay/phone", {
										y_id: this.info.y_id,
										money: money
									}, res2.tapIndex).then(
										() => {
											uni.makePhoneCall({
												phoneNumber: this.info.y_telphone
											})
										})
								}
							})
						}
					})
				} else {
					uni.makePhoneCall({
						phoneNumber: this.info.y_telphone
					})
				}
			},
			goto(item) {
				uni.navigateTo({
					url: `/hyb_o2o/addpages/pages/fuwu/fuwu?cid=${item.xt_parentid}&id=${item.xt_id}`
				})
			},

			query_orders() {
				uni.gPost("fadan/list", {
					tag: "info",
					y_id: this.info.y_id,
				}).then((list) => {
					this.orders = list;
				})
			},

			query_pingjia() {
				uni.gPost("yuangong/pingjia/list", {
					y_id: this.info.y_id
				}).then((list) => {
					this.pingjiaLit = list;
				})
			},

			navchange(index) {
				this.navIndex = index;
				this.id = this.$store.state.base.yg_set.sfzx_type_arr[this.navIndex].id;
				if (this.id == 2 && (this.pingjiaLit == null || this.pingjiaLit.length == 0)) {
					this.query_pingjia()
				} else if (this.id == 3 && (this.orders == null || this.orders.length == 0)) {
					this.query_orders()
				}
			}
		}
	}
</script>
<style scoped>
	.gui-grid-item {
		padding: 20rpx 0;
		flex: 1 1 25%;
	}

	.gui-ic-image {
		width: 68rpx;
		height: 68rpx;
		margin-bottom: 10rpx;
	}

	.pendant {
		width: 100rpx;
		height: 100rpx;
		border-radius: 100rpx;
		text-align: center;
		line-height: 100rpx;
		font-size: 55rpx;
	}
</style>